    <?php 
        $functions=$viewModel->get('functions');
        $countFunction=$viewModel->get('countFunction');
        $pageCurrent=$viewModel->get('pageCurrent');
        $pageNumber=ceil($countFunction/ROWOFPAGE);
        $i=0;
        include 'views/Include/alert.php';
     ?>
    <div class="container-fluid" style="width:97%">
            <h2>QUẢN LÝ CHỨC NĂNG</h2>
            <hr>
            <form class="form-inline" action="<?php echo BASE_URL.'function/getFunction';?>" onsubmit="return ConfirmChoiceDeleteMulti();" method="POST">
                <a href="<?php echo BASE_URL.'function/create';?>" class=""><span class="glyphicon glyphicon-plus"></span> Thêm chức năng</a>
                <div class="pull-right">
                    <input type="text" class="form-control" id="inputsearch" name="txtsearch" placeholder="Nhập từ tìm kiếm">
                    <input type="submit" class="btn btn-default" id="search-submit" name="btnsearch" value="Tìm kiếm chức năng">
                </div>
                <div class="tablenav top">
                    <select class="form-control input-sm" name="action">
                        <option selected="selected" value="">Tác vụ</option>
                        <option value="delete">Xóa </option>
                    </select>
                    <input type="submit" class="btn btn-default btn-sm" name="delete-multi" value="Áp dụng">
                    <div class="tablenav-pages">
                        <span class="displaying-num"><?php echo $countFunction;?> chỉ mục</span>
                           <!--<span class="pagination-links"><a class="first-page disabled" title="Quay lại trang đầu tiên" href="">«</a>
                                <a class="prev-page disabled" title="Quay lại trang trước" href="#">‹</a>
                                <span class="paging-input"><input class="current-page" title="Trang hiện tại" type="text" name="paged" value="1" size="1"> trên <span class="total-pages">1</span></span>
                                <a class="next-page disabled" title="Tới trang sau" href="#">›</a>
                                <a class="last-page disabled" title="Tới trang cuối" href="#">»</a></span>
                            </div>-->
                    </div>
                </div>
                <table class="table table-striped">
                    <thead>
                        <th width="3%"><input type="checkbox"></th>
                        <th class="cursor">ID</th>
                        <th class="cursor">Tên chức năng</th>
                        <th>Mô tả</th>
                    </thead>
                    <tbody>
                        <?php
                             if (is_null($functions)){
                                echo "Chưa có chức năng nào";
                             }
                             else {
                                foreach ($functions as $function) {
                                    
                        ?>
                        <tr class="click">
                                <td><input type="checkbox" name="check_list[]" value="<?php echo $function->Id; ?>"></td>
                                <td><?php echo $function->Id ?><br>
                                    <div class="row-action">
                                        <span class="edit"><a href="<?php echo BASE_URL.'function/update/'.$function->Id; ?>">Chỉnh sửa</a> |</span> 
                                        <span class="delete"><a href="<?php echo BASE_URL.'function/delete/'.$function->Id; ?>">Xóa</a></span> 
                                    </div>
                                </td>
                                <td><?php echo $function->TenChucNang; ?></td>
                                <td><?php echo $function->MoTa; ?></td>
                        </tr>
                        <?php } } ?>
                    </tbody>
                    <tfoot>
                        <th width="3%"><input type="checkbox"></th>
                        <th class="cursor">ID</th>
                        <th class="cursor">Tên chức năng</th>
                        <th>Mô tả</th>
                    </tfoot>
                </table>
                <div class="tablenav bottom" name="">
                    <select class="form-control input-sm">
                        <option selected="selected" value="">Tác vụ</option>
                        <option value="">Xóa </option>
                    </select>
                    <input type="submit" class="btn btn-default btn-sm" id name="btnapply" value="Áp dụng">
                    <div class="tablenav-pages">
                        <span class="displaying-num"><?php echo $countFunction;?>chỉ mục</span>
                           <!--<span class="pagination-links"><a class="first-page disabled" title="Quay lại trang đầu tiên" href="">«</a>
                                <a class="prev-page disabled" title="Quay lại trang trước" href="#">‹</a>
                                <span class="paging-input"><input class="current-page" title="Trang hiện tại" type="text" name="paged" value="1" size="1"> trên <span class="total-pages">1</span></span>
                                <a class="next-page disabled" title="Tới trang sau" href="#">›</a>
                                <a class="last-page disabled" title="Tới trang cuối" href="#">»</a></span>
                            </div>-->
                    </div>
                </div>
            </form>
            <!-- phân trang -->
        <div class="row">
            <div class="col-md-10">
              <?php 
                    if($pageCurrent>1){echo '<a class="btn btn-success" href="'.BASE_URL.'function/'.($pageCurrent-1).'">Trang trước</a>';}
                    echo '&nbsp;';
              for ($i=1 ; $i<=$pageNumber ; $i++) {
                if ($i == $pageCurrent) {
                       echo $i;
                       echo '&nbsp;';
                } 
                else {
                      echo '<a class="btn btn-info" href="'.BASE_URL.'function/'.$i.'">'.$i.'</a>';
                      echo '&nbsp;';
                }
              }
              if($pageCurrent<$pageNumber){echo '<a class="btn btn-success" href="'.BASE_URL.'function/'.($pageCurrent+1).'"">Trang sau</a>';}
            ?>
            </div>
        </div>
        </div>
    <script type="text/javascript">$('.list > li a').click(function() {
    $(this).parent().find('ul').toggle();
});</script> 
